 <%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%
  String xm = this.getServletContext().getInitParameter("path");
	String path1 = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+"/"+xm;
%>  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"> 
<html>
<head>
<title>接待记录列表</title>
<link href="<%=path1%>/css/css.css" rel="stylesheet" type="text/css" />
<link type="text/css" rel="stylesheet" href="<%=path1%>/scripts/pagekage/utils/widget/jqGrid/redmond/jquery-ui-1.8.2.custom.css"/>
<link type="text/css" rel="stylesheet" href="<%=path1%>/scripts/pagekage/utils/widget/jqGrid/ui.jqgrid.css"/> 
<script type="text/javascript" src="<%=path1%>/scripts/jquery-1.7.2.js"></script>
<script type="text/javascript" src="<%=path1%>/scripts/pagekage/utils/widget/jqGrid/jquery.jqGrid.src.js"></script>
<script type="text/javascript" src="<%=path1%>/scripts/pagekage/utils/widget/jqGrid/i18n/grid.locale-cn.js"></script>
<script type="text/javascript" src="<%=path1%>/scripts/pagekage/utils/widget/jqGrid/jquery.jqGrid.min.js"></script>
<!-- 日历 -->
<script type="text/javascript" src="<%=path1%>/scripts/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $("#list4").jqGrid({
        url:"./Reception_Record/selectBySql.do",
        datatype:"json", 
        mtype:"POST",
        height:420,
        //postData:"{pageSize:10,pageIndex:1,SearchSql:''}",
        autowidth:true,
       // colNames:['ID', '名称', 'qq','操作'],
       colNames:['接待记录编号','','接待内容','接待方式','接待时间','客户编号','客户姓名','业务员id','业务员'],
       colModel:[  
{name:'reception_record_id',index:'reception_record_id',hidden:true},
{name:'',index:'', width:'0%', align:'center' , formatoptions:{disabled:false} } ,
{name:'reception_content',index:'reception_content', width:'30%', align:'center'},
{name:'reception_mode',index:'reception_mode', width:'5%', align:'center'},
{name:'reception_time',index:'reception_time', width:'10%', align:'center'},
{name:'customer_id',index:'customer_id',hidden:true},
{name:'customer_name',index:'customer_name', width:'5%', align:'center'},
{name:'user_id',index:'user_id',hidden:true},
{name:'user_name',index:'user_name', width:'5%', align:'center'},
        ],
        rownumbers:true,
        //altRows:true,
        //sortname:'createDate',
        //sortorder:'asc',
        viewrecords: true, //是否显示行行数
        rowNum:8,
        rowList:[2,4,6,8,10,12],
        jsonReader:{
            id: "blackId",
            repeatitems : false
        },
        pager:$('#gridPager')
    });
});
</script>
<script type="text/javascript">  
 
    function gotoaddclient(){  
	    window.location.href='addCustomer.jsp';
    }
    function gotolistclient(){  
	    window.location.href='listCustomer.jsp';
    }
    
    function ajaxUpdate(){  
    	
    	var id=$('#list4').jqGrid('getGridParam','selrow');
    	if(id==null)
    	{
    	alert("请选择要修改的行");
    	return;
    	}
       var rowData = $('#list4').jqGrid('getRowData',id);
       updateid=rowData.reception_record_id;
       //userid=rowData.userId;
       //number=rowData.number;
       //userName=rowData.userName;
       //clientId=rowData.clientId;
       //alert("id:"+updateid);
       window.location.href = 'updateReception_Record.jsp?reception_record_id='+updateid; 
       //alert("clientId"+clientId);
       //alert("userName"+userName);
       //alert("userid"+userid);
       //alert("number"+number);
       //var array={
   		//id:rowData.id,
   		//userId:rowData.userId,
   		//receiveContent:rowData.receiveContent,
   		//reception_mode:rowData.reception_mode,
   		//reception_time:rowData.reception_time,
   		//clientId:rowData.clientId,
   		//customer_name:rowData.customer_name,
   		//userId:rowData.userId,
   		//number:rowData.number,
   		//userName:rowData.userName
   	//};
       
   //	alert("client"+array);
    //   $.ajax({ 	
    //   data: array,
    //   type:"Post",  
    //   dataType: 'json',  
    //   url:"/wangda/skip.do", 
   //    error:function(data){  
   //         alert("出错了！！");  
    //   },  
    //   success:function(data){
     //  	alert('客户信息修改成功！');
       	
    //    }  
    //    });  
       
        
     }  
    
   
    function ajaxDelete(){  
    	
        var id=$('#list4').jqGrid('getGridParam','selrow');
        if(id==null)
        	{
        	alert("请选择要删除的行");
        	return;
        	}
        var rowData = $('#list4').jqGrid('getRowData',id);
        delid=rowData.reception_record_id;
          alert(delid);

        $.ajax({  
        data: {reception_record_id:delid},  
        type:"Post",  
        dataType: 'json',  
         url:"./Reception_Record/deleteReception_Record.do",  
         error:function(data){  
             alert("出错了！！");  
         },  
        success:function(data){  
        	$("#list4").jqGrid('setGridParam',{ 
                datatype:'json', 
                postData:{'pageSize':10,'pageIndex':1,'SearchSql':""}, // 发送数据   
                page:1 
            }).trigger("reloadGrid"); 
        	 //alert("success:"+data.msg);  
            // $("#result").html(data.msg) ;  
         }  
         });  
     } 
    function ajaxSelect(){  
        /*$.ajax({  
        data: {pageSize:10,pageIndex:1,SearchSql:""},  
        type:"Post",  
        dataType: 'json',  
         url:"select.do",  
         error:function(data){  
             alert("出错了！！");  
         },  
        success:function(data){  
          // alert("success:"+data);  
            // $("#result").html(data[0]);
        }
        }); */
        var SearchSql ="";
        var customer_name=$("#customer_name").val();
        //alert(customer_name);
        var number=$("#number").val();
        //alert(number);
        var reception_mode=$("#reception_mode").val();
        //alert(reception_mode);
        var reception_time=$("#reception_time").val();
        //alert(reception_time);
        var reception_time2=$("#reception_time2").val();
        //alert(reception_time2);
          if(customer_name=="" && number=="" && reception_mode==""&& reception_time=="" ){
        	  SearchSql +="and delete_state='0'"
        	 
        		  $("#list4").jqGrid('setGridParam',{ 
                  datatype:'json', 
                  postData:{'SearchSql':""}, // 发送数据   
                  page:1 
              }).trigger("reloadGrid"); 
          }else{
        	  //SearchSql +="and delete_state='0'"
        	  if(customer_name!="" )
          	  {
          	     SearchSql +="  and customer_name like '%"+customer_name+"%'";
          	  }
        	  if(number!="" )
          	  {
          	     SearchSql +="  and number='"+number+"'";
          	  }
        	  if(reception_mode!="" )
          	  {
          	     SearchSql +="  and reception_mode='"+reception_mode+"'";
          	  }
        	  if(reception_time!="" )
          	  {
          	     SearchSql +="  and reception_time BETWEEN '"+reception_time+"' and '"+reception_time2+"'";
          	  }
          	$("#list4").jqGrid('setGridParam',{ 
              datatype:'json', 
              url:"./Reception_Record/selectBySql.do",
              postData:{'SearchSql':SearchSql}, // 发送数据     //  where name like '%"+$("#name").val()+"%'
              page:1 
          }).trigger("reloadGrid");  
          }
           
     } 
</script> 
</head>
<body>
<div id="gridPager"></div>
<div class="yboxwidth boxcenter ybox01">
<div class="ybox09">
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
       <td style="padding-left: 20px"><table border="0" cellspacing="0" cellpadding="0">
          <tr valign="top" >
            <td class="ybox11td5" ></td>
            <td class="ybox11td6" >接待记录列表</td>
            <td class="ybox11td7"></td>
            <td class="ybox11td2"></td>
            <td class="ybox11td3"></td>
            <td class="ybox11td2"></td>
            <td class="ybox11td3"></td>
            <td class="ybox11td2"></td>
            <td class="ybox11td4"></td>    
          </tr>
        </table></td>
        </tr>
    </table>
  </div>
  
  <div class="ybox02">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="margb4">
      <tr>
        <td class="ybox03td1"></td>
        <td class="ybox03td2"></td>
        <td class="ybox03td3"></td>
      </tr>
      <tr>
        <td class="ybox03td4"></td>
        <td class="ybox03td5"><div class="ybox05 margb8">
          <dl>
            <dt> <strong></strong>&nbsp;&nbsp;
                  客户姓名：<input type="text" id="customer_name"/> &nbsp;&nbsp;&nbsp;&nbsp;
	        业务员编号：<input type="text" id="number" />&nbsp;&nbsp;&nbsp;&nbsp;
	        接待方式：<input type="text" id="reception_mode" />&nbsp;&nbsp;&nbsp;&nbsp;
	        接待时间：<input type="text" id="reception_time"  class="Wdate" onclick="WdatePicker()"/> &nbsp;&nbsp;至&nbsp;&nbsp;
	           <input type="text" id="reception_time2" class="Wdate" onclick="WdatePicker()"/>&nbsp;&nbsp;
	       <img onclick="ajaxSelect()" src="images/bottonselect.gif" width="50" height="20" style="vertical-align: middle;cursor: pointer;" />
	           </dt>
          </dl>
        </div>
          <div class="ybox07 margb2">
            
      <dl><table border="0" cellspacing="0" cellpadding="0" class="ybox07table" >
              <tr align="left">
                <td class="ybox07td1"><img src="images/op4_6.gif" /></td>
                <td><span style="cursor:pointer;" onclick="ajaxUpdate()">修改接待信息</span></td>
                <td class="ybox07td2"><img src="images/op4_0.gif"  /></td>
                <td class="ybox07td1"><img src="images/op4_3.gif" /></td>
                <td><span style="cursor:pointer;" onclick="ajaxDelete()">移除接待信息</span></td>
                <td class="ybox07td2" width="55%"><img src="images/op4_0.gif" /></td>
                <td class="ybox07td2"><img src="images/op4_0.gif" /></td>
                <td class="ybox07td1" ><img src="images/op4_1.gif" width="15" height="16"/></td>
                <td ><span style="cursor:pointer;" onclick="gotoaddclient()">添加新客户信息</span></td>
                <td class="ybox07td2"><img src="images/op4_0.gif" /></td>
                <td class="ybox07td1" ><img src="images/op6_1.gif" width="15" height="16"/></td>
                <td ><span style="cursor:pointer;" onclick="gotolistclient()">返回客户信息列表</span></td>
              </tr>
          </table></dl></div>
          <table width="100%" border="0" cellpadding="0" cellspacing="1" class="ybox06table" id="list4">
                
           </table>
          </td>
        <td class="ybox03td6"></td>
      </tr>
      <tr>
        <td class="ybox03td7"></td>
        <td class="ybox03td8"></td>
        <td class="ybox03td9"></td>
      </tr>
    </table>
  </div>
</div>
</body>
</html>